{% extends 'base/base1.html' %}

{% block title %}{% if object %}编辑地址{% else %}添加地址{% endif %}{% endblock %}

{% block main %}
<div class="container">
    <div class="row justify-content-center">
        <div class="col-md-8">
            <div class="card">
                <div class="card-header">
                    <h4>{% if object %}编辑地址{% else %}添加地址{% endif %}</h4>
                </div>
                <div class="card-body">
                    <form method="post">
                        {% csrf_token %}
                        <div class="row">
                            {% if not object %}
                            <div class="col-md-12">
                                <div class="form-group">
                                    <label>用户</label>
                                    {{ form.user }}
                                </div>
                            </div>
                            {% endif %}
                            <div class="col-md-6">
                                <div class="form-group">
                                    <label>收货人</label>
                                    {{ form.recipient_name }}
                                </div>
                            </div>
                            <div class="col-md-6">
                                <div class="form-group">
                                    <label>联系电话</label>
                                    {{ form.phone }}
                                </div>
                            </div>
                            <div class="col-md-4">
                                <div class="form-group">
                                    <label>省份</label>
                                    {{ form.province }}
                                </div>
                            </div>
                            <div class="col-md-4">
                                <div class="form-group">
                                    <label>城市</label>
                                    {{ form.city }}
                                </div>
                            </div>
                            <div class="col-md-4">
                                <div class="form-group">
                                    <label>区县</label>
                                    {{ form.district }}
                                </div>
                            </div>
                            <div class="col-md-12">
                                <div class="form-group">
                                    <label>详细地址</label>
                                    {{ form.street }}
                                </div>
                            </div>
                            <div class="col-md-12">
                                <div class="form-group">
                                    <label>
                                        {{ form.is_default }} 设为默认地址
                                    </label>
                                </div>
                            </div>
                        </div>
                        <div class="form-group">
                            <button type="submit" class="btn btn-primary">保存</button>
                            <a href="{% url 'main:address_list' %}" class="btn btn-secondary">取消</a>
                        </div>
                    </form>
                </div>
            </div>
        </div>
    </div>
</div>
{% endblock %}